package com.cleaningcloud.cld.api.factory;

import com.cleaningcloud.cld.api.RemoteStaffService;
import com.cleaningcloud.cld.api.domain.CldRecruitPlan;
import com.cleaningcloud.cld.api.domain.CldStaff;
import com.cleaningcloud.cld.api.model.LoginStaff;
import com.cleaningcloud.common.core.domain.R;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class RemoteStaffFallbackFactory implements FallbackFactory<RemoteStaffService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteStaffFallbackFactory.class);
    @Override
    public RemoteStaffService create(Throwable throwable) {
        log.error("云管理服务调用失败:{}", throwable.getMessage());
        return new RemoteStaffService() {
            @Override
            public R<LoginStaff> getStaffInfo(String staffPhone, String source) {
                return R.fail("获取员工信息失败:" + throwable.getMessage());
            }

            @Override
            public R<LoginStaff> getProjectAccountInfo(String accountPhone, String source) {
                return R.fail("获取客户信息失败:" + throwable.getMessage());
            }

            @Override
            public R<Boolean> registerStaffInfo(CldStaff staff, String source) {
                return R.fail("注册失败:" + throwable.getMessage());
            }

            @Override
            public R<CldRecruitPlan> getInfoByRecruitPhone(String recruitPhone, String source) {
                return R.fail("查询招聘计划失败");
            }

            @Override
            public R<Boolean> updateStaffOpenId(CldStaff staff) {
                return R.fail("更新用户OpenId失败");
            }
        };
    }
}
